<template>
  <div>
    <el-dialog append-to-body title="踢回公海" :visible.sync="open">
      <el-form ref="form" :model="form" :rules="rules">
        <el-row>
          <el-col :span="24">
            <el-form-item label="原因" prop="record" >
                        <el-select v-model="form.record" placeholder="请选择原因">
                          <el-option v-for="item in dict.type.reasons_for_business_reporting" :label="item.label" :key="item.value" :value="item.label">
                          </el-option></el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click=" open= false">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {giveBackBusiness} from '../../../api/crm/businesstrack'
    export default {
        name: "give-back",
      dicts:['reasons_for_business_reporting'],
      props:['businessId'],

      data(){
          return{
            form:{},
            open:false,
            rules:{
              record:[{
                required:true,message:"原因不能为空",trigger:"change"
              }]
            }
          }
      },
      methods:{
          restform(){
            this.form={
              id:null,
              record:null
            }
          },
        submitForm(){
            this.$refs.form.validate(valid=>{
              if(valid){
                this.form.id=this.businessId
                giveBackBusiness(this.businessId,this.form).then(resp=>{
                  this.$modal.msgSuccess("操作成功！")
                  this.$emit("success")
                })
                .catch(()=>{
                  this.$modal.msgError("操作失败")
                })
                this.open=false
              }
            })
        }
      },
      created() {
      }
    }
</script>

<style scoped>

</style>
